<script type="text/javascript">
$(function(){
	var pg = App.soagov.comIndex.ui
		, frm = pg.find(".form")
		, tabs = pg.find('.tabs')
		, infoPl = pg.find('.infoPl')
		, byMePl = pg.find('.byMePl')
		, byMeGd = pg.seek('byMeGd')
		, onMePl = pg.find('.onMePl')
		, onMeGd = pg.seek('onMeGd');

	tabs.mac('tabs', {
		tabWidth: 80,
		tabHeight: 32,
		items: [{
			code: 'infoPl',
			title: '基本信息',
			el: infoPl
		},{
			code: 'byMePl',
			title: '依赖项',
			el: byMePl
		},{
			code: 'onMePl',
			title: '被依赖项',
			el: onMePl
		}]
	}).selectFirst();
	
	byMeGd.mac('grid', {
		cols : [{
			field: 'code', title : '组件编号', width: 140,
			render: function(r){
				return r.objCode1;
			}
		},{
			field: 'name', title : '组件名称', width: 160,
			render: function(r){
				return r.objName1;
			}
		},{
			field: 'ver', title : '组件版本', width: 80,
			render: function(r){
				return r.objVer1;
			}
		},{
			field: 'async', title : '异步', width: 40,
			render: function(r){
				return r.async? '是':'否';
			}
		},{
			field: 'way', title : '方式', width: 120
		},{
			field: 'memo', title : '备注', width: 200
		}]
	});

	onMeGd.mac('grid', {
		cols : [{
			field: 'code', title : '组件编号', width: 140,
			render: function(r){
				return r.objCode0;
			}
		},{
			field: 'name', title : '组件名称', width: 160,
			render: function(r){
				return r.objName0;
			}
		},{
			field: 'ver', title : '组件版本', width: 80,
			render: function(r){
				return r.objVer0;
			}
		},{
			field: 'async', title : '异步', width: 40,
			render: function(r){
				return r.async? '是':'否';
			}
		},{
			field: 'way', title : '方式', width: 120
		},{
			field: 'memo', title : '备注', width: 200
		}]
	});

	function adjust(){
		var h = pg.parent().height();
		pg.height(h-30);
		//tabs.width(pg.width() - frm.width());
		tabs.height(h-30);
		tabs.adjust();
		h = tabs.children('.body').height();
		onMeGd.parent().height(h - 44);
		onMeGd.adjust();
		byMeGd.parent().height(h - 44);
		byMeGd.adjust();
	}
	$(window).resize(adjust);
	adjust();
	
	function init(co, by, on, fc){
		frm.seek('code').text(co.code)
			.attr('href', App.soagov.ctx + '/#flow/edit?type=com&id=' + co.id);
		frm.seek('code').text(co.code).attr('target',"_blank");
		frm.seek('name').text(co.name);
		frm.seek('type').text(co.type);
		frm.seek('faceCode').text(co.face.code);
		frm.seek('faceName').text(co.face.name);
		frm.seek('faceEntry').text(co.face.entry);
		frm.seek('faceVer').text(co.face.version);
		frm.seek('impl').text(co.impl);
		frm.seek('ver').text(co.version);
		frm.seek('memo').text(co.memo);
		//frm.seek('owner').text(co.owner);
		frm.seek('status').text(Cache.base.com.status[co.status]);
		var op = $('<span class="a"></span>');
		if (co.status == 0) {
			op.click(function(){
				
			}).append('启用');
		} else {
			op.click(function(){
				
			}).append('停用');
		}
		frm.seek('opt').append(op);
		frm.seek('memo').text(co.memo);		
		//
		byMeGd.loadData($.map(by, function(v, k){
			return k != '0'? v:null;
		}));
		onMeGd.loadData($.map(on, function(v, k){
			return k != '0'? v:null;
		}));
	}

	var w = mac.wait('Loading');
	$.get(App.soagov.ctx + '/com/get.do', {
		id: pg.params.id
	}, function(rs) {
		var ro = mac.eval(rs);
		if (ro.success) {
			init(ro.data, ro.byMe, ro.onMe);
		} else {
			mac.alert(ro.data, ro.params);
		}
		w.close();
	});
});
</script>
<div class="tabs"></div>
<div class="infoPl form">
	<div class="item">
		<span class="label">组件名：</span> <a class="value" name="code"></a>
	</div>
	<div class="item">
		<span class="label">组件中文名：</span> <span class="value" name="name"></span>
	</div>
	<div class="item">
		<span class="label">组件类型：</span> <span class="value" name="type"></span>
	</div>
	<div class="item">
		<span class="label">接口名：</span> <span class="value" name="faceCode"></span>
	</div>
	<div class="item">
		<span class="label">接口中文名：</span> <span class="value" name="faceName"></span>
	</div>
	<div class="item">
		<span class="label">入口：</span> <span class="value" name="faceEntry"></span>
	</div>
	<div class="item">
		<span class="label">接口版本：</span> <span class="value" name="faceVer"></span>
	</div>
	<div class="item">
		<span class="label">实现：</span> <span class="value" name="impl"></span>
	</div>
	<div class="item">
		<span class="label">版本：</span> <span class="value" name="ver"></span>
	</div>
	<div class="item">
		<span class="label">状态：</span> <span class="value" name="status"></span>
	</div>
	<div class="item">
		<span class="label">描述：</span> <span class="memo" name="memo"></span>
	</div>
</div>
<div class="byMePl">
	<div class="head">当前流程务依赖以下组件或服务</div>
	<div class="body">
		<div class="grid" name="byMeGd"></div>
	</div>
</div>
<div class="onMePl">
	<div class="head">当前流程被以下对象组件或服务依赖</div>
	<div class="body">
		<div class="grid" name="onMeGd"></div>
	</div>
</div>